#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：Employment_class 
@File    ：02_list.py
@IDE     ：PyCharm 
@Author  ：XiaoDengYa
@Date    ：2021/7/29/029 20:44 
"""

from timeit import Timer


def demo1():
    li = []
    for i in range(10000):
        li.append(i)


def demo2():
    li = []
    for i in range(10000):
        li += [i]


def demo3():
    li = [i for i in range(10000)]


def demo4():
    li = list(range(10000))


def demo5():
    li = []
    for i in range(10000):
        li.extend([i])


if __name__ == '__main__':
    timer1 = Timer('demo1()', "from __main__ import demo1")
    print("+", timer1.timeit(1000))
    timer2 = Timer('demo2()', "from __main__ import demo2")
    print("+", timer2.timeit(1000))
    timer3 = Timer('demo3()', "from __main__ import demo3")
    print("+", timer3.timeit(1000))
    timer4 = Timer('demo4()', "from __main__ import demo4")
    print("+", timer4.timeit(1000))
    timer5 = Timer('demo5()', "from __main__ import demo5")
    print("+", timer5.timeit(1000))